package com.credithc.fastdfs.monitor.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.credithc.fastdfs.api.entity.DownloadFileRecord;
import com.credithc.fastdfs.api.entity.FdfsInfo;
import com.credithc.fastdfs.api.mapper.DownloadFileRecordMapper;
import com.credithc.fastdfs.api.mapper.FdfsInfoMapper;
import com.credithc.fastdfs.monitor.service.FileDataService;

@Service
public class FileDataServiceImpl implements FileDataService {

	@Autowired
	private FdfsInfoMapper fim;
	@Autowired
	DownloadFileRecordMapper dfrm;

	@Override
	public List<FdfsInfo> getFileListByGroupName(String groupName) {
		List<FdfsInfo> files = new ArrayList<FdfsInfo>();
		files = fim.getFileListByGroupName(groupName);
		return files;
	}

	@Override
	public DownloadFileRecord getDownloadFileRecordByIpAndFileId(String ip,
			String fileId) {
		Map<String, String> map = new HashMap<String, String>();
		map.put(ip, ip);
		map.put(fileId, fileId);
		return dfrm.getDownloadFileRecordByIpAndFileId(ip, fileId);
	}

	@Override
	public void saveDF(DownloadFileRecord downloadFileRecord) {
		dfrm.insert(downloadFileRecord);
	}
}
